package com.nulstudio.sppm;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.util.Objects;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class NulHitSppm16BackApplication {

    public static void main(String[] args) {
        SpringApplication.run(NulHitSppm16BackApplication.class, args);
    }

    public static final class Result<T> {
        private final int version = 1;

        private final int code;

        private final String message;

        private final T result;


        public Result(T result) {
            this.code = 0;
            this.message = "";
            this.result = result;
        }

        public Result(int code, String message) {
            this.code = 0;
            this.message = message;
            this.result = null;
        }

        public int getVersion() {
            return version;
        }

        public int getCode() {
            return code;
        }

        public String getMessage() {
            return message;
        }

        public Object getResult() {
            return result;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            final Result<?> result1 = (Result<?>) o;
            return code == result1.code && Objects.equals(message, result1.message)
                    && Objects.equals(result, result1.result);
        }

        @Override
        public int hashCode() {
            return Objects.hash(version, code, message, result);
        }
    }

    public static final class Request<T> {
        private final int version;

        private final T request;

        public Request(int version, T request) {
            this.version = version;
            this.request = request;
        }

        public Request() {
            this.version = 0;
            this.request = null;
        }

        public int getVersion() {
            return version;
        }

        public T getRequest() {
            return request;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Request<?> request1 = (Request<?>) o;
            return version == request1.version && Objects.equals(request, request1.request);
        }

        @Override
        public int hashCode() {
            return Objects.hash(version, request);
        }
    }

    public static final class UpdateNameRequest {
        private final int uid;

        private final String name;


        public UpdateNameRequest() {
            this.uid = 0;
            this.name = null;
        }

        public UpdateNameRequest(int uid, String name) {
            this.uid = uid;
            this.name = name;
        }

        public int getUid() {
            return uid;
        }

        public String getName() {
            return name;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            UpdateNameRequest that = (UpdateNameRequest) o;
            return uid == that.uid && Objects.equals(name, that.name);
        }

        @Override
        public int hashCode() {
            return Objects.hash(uid, name);
        }
    }
}
